package com.jinniulive.platform.tools;

import android.app.Activity;

import com.jinniulive.platform.MyApp;
import com.jinniulive.platform.bean.LoginInfo;

/**
 * Created by Administrater on 2016/12/8.
 */

public class GetInfoUtil {
    private static GetInfoUtil instance;

    private GetInfoUtil() {

    }

    public static GetInfoUtil getInstance() {
        if (instance==null){
            synchronized (GetInfoUtil.class){
                if(instance==null){
                    instance = new GetInfoUtil();
                }
            }
        }
        return instance;
    }

    private MyApp getMyApp(Activity activity) {
        return (MyApp) activity.getApplication();
    }

    private LoginInfo getUserInfo(Activity activity) {
        return getMyApp(activity).getLoginInfo();
    }

    private LoginInfo.UserslistBean getUserslistBean(Activity activity) {
        return getUserInfo(activity).getUserslist().get(0);
    }

    public String getTokenId(Activity activity) {
        return getUserslistBean(activity).getTokenID();
    }

    public int getUserId(Activity activity) {
        return getUserslistBean(activity).getUserID();
    }
}
